using System;
using Dto;
using UnityEngine;
using UnityEngine.UI;

namespace UI
{
    public class UpPanel : UIBase
    {
        /**
         * 
         */
        private Image[] _imgCards = null;

        private void Awake()
        {
            Bind(UIEvent.SET_TABLE_CARDS);
        }

        public override void Execute(int eventCode, object message)
        {
            switch (eventCode)
            {
                case UIEvent.SET_TABLE_CARDS:
                    SetTableCards(message as CardDto[]);
                    break;
                default:
                    break;
            }
        }

        void Start()
        {
            _imgCards = new Image[3];
            _imgCards[0] = transform.Find("ImgCard1").GetComponent<Image>();
            _imgCards[1] = transform.Find("ImgCard2").GetComponent<Image>();
            _imgCards[2] = transform.Find("ImgCard3").GetComponent<Image>();
        }

        /// <summary>
        /// 设置底牌
        /// </summary>
        private void SetTableCards(CardDto[] cards)
        {
            //TODO 
            _imgCards[0].sprite = Resources.Load<Sprite>("Pokeer/"+cards[0].name);
            _imgCards[1].sprite = Resources.Load<Sprite>("Pokeer/"+cards[1].name);
            _imgCards[2].sprite = Resources.Load<Sprite>("Pokeer/"+cards[2].name);
        }
    }
}